#include "rkmedia_module_container.h"
#include <stdio.h>

containerInfo::containerInfo()
{
    printf("this is containerInfo Init...\n");
    memset(&above_container, 0, sizeof(RV1126_ALLUSED_CONTAINER));
    pthread_mutex_init(&container_mutex, NULL);
}

containerInfo::~containerInfo()
{
    printf("this is containerInfo destroyed...\n");
    pthread_mutex_destroy(&container_mutex);
}

int containerInfo::set_vi_container(unsigned int index, RV1126_VI_CONTAINER *vi_container)
{
    pthread_mutex_lock(&container_mutex);
    above_container.vi_container[index].index = index;
    above_container.vi_container[index].vi_chn = vi_container->vi_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::set_venc_container(unsigned int index, RV1126_VENC_CONTAINER *venc_container)
{
    pthread_mutex_lock(&container_mutex);
    above_container.venc_container[index].index = index;
    above_container.venc_container[index].venc_chn = venc_container->venc_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::set_rga_container(unsigned int index, RV1126_RGA_CONTAINER *rga_container)
{
    pthread_mutex_lock(&container_mutex);
    above_container.rga_container[index].index = index;
    above_container.rga_container[index].rga_chn = rga_container->rga_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::set_ai_container(unsigned int index, RV1126_AI_CONTAINER *ai_container)
{
    pthread_mutex_lock(&container_mutex);
    above_container.ai_container[index].index = index;
    above_container.ai_container[index].ai_chn = ai_container->ai_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::set_aenc_container(unsigned int index, RV1126_AENC_CONTAINER *aenc_container)
{
    pthread_mutex_lock(&container_mutex);
    above_container.aenc_container[index].index = index;
    above_container.aenc_container[index].aenc_chn = aenc_container->aenc_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::get_vi_container(unsigned int index, RV1126_VI_CONTAINER *vi_container)
{
    pthread_mutex_lock(&container_mutex);
    index = above_container.vi_container[index].index;
    vi_container->vi_chn = above_container.vi_container[index].vi_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::get_venc_container(unsigned int index, RV1126_VENC_CONTAINER *venc_container)
{
    pthread_mutex_lock(&container_mutex);
    index = above_container.venc_container[index].index;
    venc_container->venc_chn = above_container.venc_container[index].venc_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::get_rga_container(unsigned int index, RV1126_RGA_CONTAINER *rga_container)
{
    pthread_mutex_lock(&container_mutex);
    index = above_container.rga_container[index].index;
    rga_container->rga_chn = above_container.rga_container[index].rga_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::get_ai_container(unsigned int index, RV1126_AI_CONTAINER *ai_container)
{
    pthread_mutex_lock(&container_mutex);
    index = above_container.ai_container[index].index;
    ai_container->ai_chn = above_container.ai_container[index].ai_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}

int containerInfo::get_aenc_container(unsigned int index, RV1126_AENC_CONTAINER *aenc_container)
{
    pthread_mutex_lock(&container_mutex);
    index = above_container.aenc_container[index].index;
    aenc_container->aenc_chn = above_container.aenc_container[index].aenc_chn;
    pthread_mutex_unlock(&container_mutex);
    return 0;
}
